<?php
namespace BoxMall\Logic;
class OrderLogic extends \LogicController {
	public function index() {

	}
	/****生成订单**/
//	$row=array(
	//		   'store_id'=>1,
	//		   'user_id'=>$this->user_id,
	//		   'payment_id'=>$data['payment_id'],
	//		   'order_amount'=>$this->order_amount,
	//		   'suceess_url'=>$suceess_url,
	//		   'title'=>'购买课程，名称：'.$subject['subject'].",订单号：".$order_sn,
	//		   'body'=>'购买课程，名称：'.$subject['subject'].",订单号：".$order_sn,
	//		 );
	public function add(&$data) {
		if (!$data['order_sn']) {
			$data['order_sn'] = createOrderNo();
		}
		$data['addtime'] = date("Y-m-d H:i:s");
		$type = $data['order_type'];
		hook("order_before_make", $data);
		hook("order_before_make_" . $type, $data);
		$model = BoxModel("SystemOrder");
		$data['yie'] = $data['use_yie'];
		$row = $model->create($data);
		$order_id = $model->add($row);
		//dump($type);exit();
		if ($order_id) {
			hook("order_after_make", $data);
			hook("order_after_make_" . $type, $data);
			$orderData = BoxModel("system_order")->load($data['order_sn']);
		}

		return $orderData;
	}

}